package org.wxd.ms.stu.consumer.web;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * fallback整合hystrix，断容器实现
 * Created by wangxd on 2017/6/12.
 */
@FeignClient(name = "stu-service",fallback = UserFeignClientFallback.class)
public interface UserFeignClient {

    @GetMapping("/user/{id}")
    User findById(@PathVariable("id") Long id);
}

@Component
class UserFeignClientFallback implements UserFeignClient{

    @Override
    public User findById(Long id) {
        User user = new User();
        user.setId(id);
        user.setName("default-feign");
        user.setAddr("default-feign");
        user.setAge(1000);
        return user;
    }
}
